#include "OiPCH.hpp"
#include "OiToolCommand.hpp"

namespace Oi
{
    namespace PLScannerCore
    {
        class ToolDelCommandImpl : public Impl<ToolDelCommand>
        {
        public:
            ToolData _data;
        };

        ToolDelCommand::ToolDelCommand(int toolType, QMap<QString, QVariant> config)
        {
            OI_I(ToolDelCommand);

            d->_data.toolType = toolType;
            d->_data.config = config;
        }

        ToolDelCommand::~ToolDelCommand()
        {
            OI_E(ToolDelCommand);
        }

        void ToolDelCommand::reto()
        {
            OI_I(ToolDelCommand);

            ToolPtr tool = ToolViewer::OiToolViewer()->addTool(d->_data.toolType);
            ToolViewer::OiToolViewer()->releaseSelected();
            tool->setConfig(d->_data.config);
            tool->onLocation();
            tool->onCalculate();
        }
    }
}

